package com.party.core.service.commune.impl;

import com.party.common.paging.Page;
import com.party.core.dao.read.commune.CMomentReadDao;
import com.party.core.dao.write.commune.CMomentWriteDao;
import com.party.core.model.BaseModel;
import com.party.core.model.commune.CMoment;
import com.party.core.model.member.CMomentOutput;
import com.party.core.service.commune.ICMomentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;
import java.util.Map;
import java.util.Set;

/**
 * @program: party
 * @description: 动态业务接口实现
 * @author: Hua Qunhao
 * @create: 2019-12-18 15:53
 **/
@Service
public class CMomentService implements ICMomentService {

    @Autowired
    private CMomentWriteDao cMomentWriteDao;
    @Autowired
    private CMomentReadDao cMomentReadDao;

    @Override
    public String insert(CMoment cMoment) {
        BaseModel.preInsert(cMoment);
        boolean result = cMomentWriteDao.insert(cMoment);
        if (result) {
            return cMoment.getId();
        }
        return null;
    }

    @Override
    public boolean update(CMoment cMoment) {
        cMoment.setUpdateDate(new Date());
        return cMomentWriteDao.update(cMoment);
    }

    @Override
    public boolean deleteLogic(String id) {
        return false;
    }

    @Override
    public boolean delete(String id) {
        return cMomentWriteDao.delete(id);
    }

    @Override
    public boolean batchDeleteLogic(Set<String> ids) {
        return false;
    }

    @Override
    public boolean batchDelete(Set<String> ids) {
        return false;
    }

    @Override
    public CMoment get(String id) {
        return cMomentReadDao.get(id);
    }

    @Override
    public List<CMoment> listPage(CMoment cMoment, Page page) {
        return cMomentReadDao.listPage(cMoment,page);
    }

    @Override
    public List<CMoment> list(CMoment cMoment) {
        return cMomentReadDao.listPage(cMoment,null);
    }

    @Override
    public List<CMoment> batchList(Set<String> ids, CMoment cMoment, Page page) {
        return null;
    }

    @Override
    public List<CMoment> webListPage(Map<String, Object> params, Page page) {
        return cMomentReadDao.webListPage(params,page);
    }

    @Override
    public List<CMoment> mobileListPage(Map<String, Object> params, Page page) {
        return cMomentReadDao.mobileListPage(params,page);
    }
}
